package com.lyf.scm.admin.domain.remote.allocationservice.facade;

import com.lyf.scm.admin.domain.remote.allocationservice.SalesPlanPermissionsRemote;
import com.lyf.scm.admin.domain.remote.allocationservice.dto.SalesPlanPermissionsDTO;
import com.lyf.scm.common.enums.ResponseMsg;
import com.rome.arch.core.clientobject.Response;
import com.rome.arch.core.exception.RomeException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Martin
 * @date 2020-11-01 19:34
 */
@Service
@Slf4j
public class SalesPlanPermissionsFacade {

    @Resource
    private SalesPlanPermissionsRemote salesPlanPermissionsRemote;

    public List<SalesPlanPermissionsDTO> listByUserId(Long userId) {
        log.info("查询权限:userId:{}",userId);
        Response<List<SalesPlanPermissionsDTO>> response = salesPlanPermissionsRemote.listByUserId(userId);
        if (!response.getCode().equals(ResponseMsg.SUCCESS.getCode())) {
            throw new RomeException(response.getCode(), response.getMsg());
        }
        return response.getData();
    }
}
